package com.gopay.cashier.domain.bean;

import com.gopay.common.constants.trans.PayChannel;
import com.gopay.common.constants.trans.PayChannelType;
import com.gopay.common.domain.BaseEntity;
import com.gopay.remote.solution.vo.PayChannelDtlInfo;
import org.apache.commons.lang.StringUtils;

import java.util.List;
import java.util.Map;

public class PayChannelWayBean  extends BaseEntity {

	private static final long serialVersionUID = -2219329129627038371L;

	/** 默认用户类型：01-个人，02-企业 */
    private String defalutPayUserType;
    
    private List<PayChannelDtlBean> payChannelList;

	public String getDefalutPayUserType() {
		return defalutPayUserType;
	}

	public void setDefalutPayUserType(String defalutPayUserType) {
		this.defalutPayUserType = defalutPayUserType;
	}

	public List<PayChannelDtlBean> getPayChannelList() {
		return payChannelList;
	}

	public void setPayChannelList(List<PayChannelDtlBean> payChannelList) {
		this.payChannelList = payChannelList;
	}
    
    public boolean hasPayChannel(){
    	return payChannelList!=null && payChannelList.size()>0;
    }
    
    public PayChannelDtlBean getPayChannelDtl(String payChannelType){
    	if(hasPayChannel()){
    		for(PayChannelDtlBean bean : payChannelList){
    			if(StringUtils.equals(payChannelType, bean.getPayChannelType())){
    				return bean;
    			}
    		}
    	}
    	return null;
    }
    
    /**
     * 是否支持交易
     * @param payChannelType
     * @return
     */
    public boolean isSupport(String payChannelType){
    	return getPayChannelDtl(payChannelType)!=null;
    }
    
    /**
     * 企业充值 去掉个人银行数据
     */
    public void removeCorpInChargeBanks(){
    	try {
			PayChannelDtlBean bean = getPayChannelDtl(PayChannelType.OUTSTLM_PAY.value);
			if(bean!=null){
				Map<String, List<PayChannelDtlInfo>> map = bean.getBankCodes();
				List<PayChannelDtlInfo> personalBanks = map.get(PayChannel._01.value);
				if(personalBanks!=null && personalBanks.size()>0){
					map.remove(PayChannel._01.value);
				}
			}
		} catch (Exception e) {
			
		}
    }
}
